package com.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.ParkinglotMapper;
import com.pojo.Parkinglot;
import com.service.ParkingLotService;
import com.vo.ParkingLotVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ParkingLotServiceimpl implements ParkingLotService {
    @Resource
    private ParkinglotMapper parkinglotMapper;
    @Override
    public PageInfo<Parkinglot> selectalllot(ParkingLotVo parkingLotVo) {
        PageHelper.startPage(parkingLotVo.getPage(),parkingLotVo.getLimit());
        List<Parkinglot> selectalllot = parkinglotMapper.selectalllot(parkingLotVo);
        PageInfo<Parkinglot> pageInfo=new PageInfo<>(selectalllot);
        return pageInfo;
    }

    @Override
    public void insert(Parkinglot parkinglot) {
        parkinglotMapper.insert(parkinglot);
    }

    @Override
    public void updatestatebyid(Integer id, Integer stateid) {
        parkinglotMapper.updatestatebyid(id,stateid);
    }
    @Override
    public PageInfo<Parkinglot> selectAllLinShi(ParkingLotVo parkingLotVo) {
        PageHelper.startPage(parkingLotVo.getPage(),parkingLotVo.getLimit());
        List<Parkinglot> parkinglots = parkinglotMapper.selectAllLinShiLot(parkingLotVo);
        PageInfo<Parkinglot> pageInfo=new PageInfo<>(parkinglots);
        return pageInfo;
    }

    @Override
    public int updateStateById(Integer id) {
        int i = parkinglotMapper.updateStateById(id);
        return i;
    }

    @Override
    public int updateNullStateById(Integer id) {
        int i = parkinglotMapper.updateStateNullById(id);
        return i;
    }

    @Override
    public Parkinglot selectParkingLotById(Integer id) {
        Parkinglot parkinglot = parkinglotMapper.selectParkingLotById(id);
        return parkinglot;
    }
}
